#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6;
int t,n,a[N + 5],ans;
bool c[N + 5];
void dfs(int d){
	if(d >= n){
		int cnt = 0;
		for(int i = 1;i <= n;i++){
			for(int j = i - 1;j >= 1;j--){
				if(c[i] == c[j] &&  a[i] == a[j]){
					cnt += a[i];
					break;
				}
			}
			ans = max(ans,cnt);
		}
		return;
	}
	c[d] = true;
	dfs(d + 1);
	c[d] = false;
	dfs(d + 1);
}
signed main(){
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	cin >> t;
	while(t--){
		cin >> n;
		ans = 0;
		for(int i = 1;i <= n;i++){
			cin >> a[i];
		}
		dfs(0);
		cout << ans << endl;
	}
	fclose(stdin);
    fclose(stdout);
	return 0;
}
